package java面向对象.封装;

public class Student {
    private String name;
    private int age;
    public void read(){
        System.out.println("姓名"+name+"年龄"+age);

    }
    //赋值年龄的方法
    public void SetAge(int num){
        if(num<0||num>150){
            System.out.println("你给的年龄不合理");
        }else{
            age=num;

        }
    }
    //获取年龄的方法
    public int getAge(){
        return age;
    }

}
